var vue_vm_list = $('#vue_vm_list').html();

$(function() {
	$('#vue_vm_list div').hide();
	elderPayReturnApply_findOnaylanmam();
});

var elderPayReturnApply = {
	elderPayReturnApplyId: '',
	costDesc: '',
	elderId: '',
	elderName: '',
	elderCardId: '',
	payMoney: '',
	payDate: '',
	createTime: '',
	updateTime: '',
	updateId: getLoginedUser()? getLoginedUser().updateId:'',
	remark: '',
	payStatus: '',
	payWay: '',
	elderPayRecordId: '',
	returnReason: '',
	resultStatus: '',
	subjectRoomId: '',
	createId: getLoginedUser()? getLoginedUser().createId:'',
	approveId: '',
	approveDate: '',
	applyDate: ''
};



function elderPayReturnApply_findOnaylanmam() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	
	openWaiting('正在查找');
	
	findAll_basic(path+'/elderPayReturnApply/findOnaylanmam', function(response) {
		closeWaiting();
		
		$('#vue_vm_list').html(vue_vm_list);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				onClickElderArrearageCheckbox:function(todo) {
						var totalPayMoney = 0;
						$('ul').each(function() {
							if($(this).find('.magic-checkbox').is(':checked')) {
								var payMoney = $(this).find('.magic-checkbox').attr('arrearageMoney');
								totalPayMoney += payMoney;
							}
						});
						
						$('#payMoney').val(totalPayMoney);
				}
			}
		});
		
		if(response.data.length>0) {
			global_elderId = response.data[0].elderId;
		}
		
		$('#vue_vm_list div').show();
	});
}

function elderPayReturnApply_confirm(type) {
	var payWay = parseInt($('input:radio[name="payWay"]:checked').val());
	var payMoney = parseInt($('#payMoney').val());
	// var payIdStr = '';
	var ids = "";
	
	$('ul').each(function() {
		if($(this).find('.magic-checkbox').is(':checked')) {
			var id = $(this).find('.magic-checkbox').attr('id');
            if(id){
                ids+=id+","
            }
		}
	});

	save_basic_by_json(path+'/elderPayReturnApply/updateResultBatch', {"ids":ids,"resultStatus":type}, function() {
		alert('退费成功');
        elderPayReturnApply_findOnaylanmam();
		// window.print();
	});
}